package com.online.servlet.admin;

import com.online.dao.user.UserDao;
import com.online.pojo.UpComing_Shop;
import com.online.service.user.Impl.ShopServiceImpl;
import com.online.service.user.Impl.UserServiceImpl;
import com.online.service.user.ShopService;
import com.online.service.user.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/agreeShop")
public class agreeShopServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        System.out.println("agreeShop");
        String name = req.getParameter("name");
        String username = req.getParameter("username");
        System.out.println("agree : name="+ name+"username="+username);
        ShopService shopService = new ShopServiceImpl();
        UserService userService = new UserServiceImpl();
        try {

            shopService.agree(name);
            userService.editPermission(username);
            shopService.overrule(name);
            req.getRequestDispatcher("/reload").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
